import Vue from 'vue'
import Router from 'vue-router'
// import Home from '@/components/Home/Home'
// import Member from '@/components/Member/Member'
// import Search from '@/components/Search/Search'
// import Shopcar from '@/components/Shopcar/Shopcar'
// import NewsList from '@/components/News/NewsList'
// import NewsDetails from '@/components/News/NewsDetails'
// import PhotoList from '@/components/Photo/PhotoList'
// import PhotoDetails from '@/components/Photo/PhotoDetails'
// import GoodsList from '@/components/Goods/GoodsList'
// import GoodsDetails from '@/components/Goods/GoodsDetails'
// import GoodsComments from '@/components/Goods/GoodsComments'
// 以上常规加载 会导致app.js包越来越大
// 以下是懒加载 会根据访问情况按需加载路由
const Home = () => import('@/components/Home/Home');
const Member = () => import('@/components/Member/Member');
const Search = () => import('@/components/Search/Search');
const Shopcar = () => import('@/components/Shopcar/Shopcar');
const NewsList = () => import('@/components/News/NewsList');
const NewsDetails = () => import('@/components/News/NewsDetails');
const PhotoList = () => import('@/components/Photo/PhotoList');
const PhotoDetails = () => import('@/components/Photo/PhotoDetails');
const GoodsList = () => import('@/components/Goods/GoodsList');
const GoodsDetails = () => import('@/components/Goods/GoodsDetails');
const GoodsComments = () => import('@/components/Goods/GoodsComments');

Vue.use(Router)

export default new Router({
  routes: [
    {
      path: '/',
      redirect: { name: 'home' }
    },
    {
      path: '/home',
      name: 'home',
      component: Home
    },
    {
      path: '/Search',
      name: 'search',
      component: Search
    },
    {
      path: '/Member',
      name: 'member',
      component: Member
    },
    {
      path: '/Shopcar',
      name: 'shopcar',
      component: Shopcar
    },
    {
        name: 'news.list',
        path: '/news/list',
        component: NewsList
    },
    // 新闻详情
    {
        name: 'news.details',
        path: '/news/details',
        component: NewsDetails
    },
    // 图文列表
    {
      name: 'photo.list',
      path: '/photo/list/:categoryId',
      component: PhotoList
    },
    // 图文详情
    {
      name: 'photo.details',
      path: '/photo/details',
      component: PhotoDetails
    },
    // 商品列表
    {
      name: 'goods.list',
      path: '/goods/list',
      component: GoodsList
    },
    // 商品相亲
    {
      name: 'goods.details',
      path: '/goods/details/:id',
      component: GoodsDetails
    },
    // 图文详情
    {
        name: 'imagetext.details',
        path: '/imagetext/details/:id',
        component: NewsDetails
    },
    // 商品评论
    {
        name: 'goods.comments',
        path: '/goods/comments/:id',
        component: GoodsComments
    },
  ]
})
